home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / CIncludes / Resources.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  12.1 KB  |  427 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Resources.h
  3.  
  4.      Contains:    Resource Manager Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8.1
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __RESOURCES__
  18. #define __RESOURCES__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23. #ifndef __MIXEDMODE__
  24. #include <MixedMode.h>
  25. #endif
  26. #ifndef __FILES__
  27. #include <Files.h>
  28. #endif
  29.  
  30.  
  31.  
  32. #if PRAGMA_ONCE
  33. #pragma once
  34. #endif
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. #if PRAGMA_IMPORT
  41. #pragma import on
  42. #endif
  43.  
  44. #if PRAGMA_STRUCT_ALIGN
  45.     #pragma options align=mac68k
  46. #elif PRAGMA_STRUCT_PACKPUSH
  47.     #pragma pack(push, 2)
  48. #elif PRAGMA_STRUCT_PACK
  49.     #pragma pack(2)
  50. #endif
  51.  
  52.  
  53.  
  54. enum {
  55.     resSysHeap                    = 64,                            /*System or application heap?*/
  56.     resPurgeable                = 32,                            /*Purgeable resource?*/
  57.     resLocked                    = 16,                            /*Load it in locked?*/
  58.     resProtected                = 8,                            /*Protected?*/
  59.     resPreload                    = 4,                            /*Load in on OpenResFile?*/
  60.     resChanged                    = 2,                            /*Resource changed?*/
  61.     mapReadOnly                    = 128,                            /*Resource file read-only*/
  62.     mapCompact                    = 64,                            /*Compact resource file*/
  63.     mapChanged                    = 32                            /*Write map out at update*/
  64. };
  65.  
  66.  
  67. enum {
  68.     resSysRefBit                = 7,                            /*reference to system/local reference*/
  69.     resSysHeapBit                = 6,                            /*In system/in application heap*/
  70.     resPurgeableBit                = 5,                            /*Purgeable/not purgeable*/
  71.     resLockedBit                = 4,                            /*Locked/not locked*/
  72.     resProtectedBit                = 3,                            /*Protected/not protected*/
  73.     resPreloadBit                = 2,                            /*Read in at OpenResource?*/
  74.     resChangedBit                = 1,                            /*Existing resource changed since last update*/
  75.     mapReadOnlyBit                = 7,                            /*is this file read-only?*/
  76.     mapCompactBit                = 6,                            /*Is a compact necessary?*/
  77.     mapChangedBit                = 5                                /*Is it necessary to write map?*/
  78. };
  79.  
  80.  
  81. enum {
  82.     kResFileNotOpened            = -1,                            /*ref num return as error when opening a resource file*/
  83.     kSystemResFile                = 0                                /*this is the default ref num to the system file*/
  84. };
  85.  
  86.  
  87. typedef CALLBACK_API( void , ResErrProcPtr )(OSErr thErr);
  88. /*
  89.     WARNING: ResErrProcPtr uses register based parameters under classic 68k
  90.              and cannot be written in a high-level language without 
  91.              the help of mixed mode or assembly glue.
  92. */
  93. typedef REGISTER_UPP_TYPE(ResErrProcPtr)                         ResErrUPP;
  94. enum { uppResErrProcInfo = 0x00001002 };                         /* register no_return_value Func(2_bytes:D0) */
  95. #define NewResErrProc(userRoutine)                                 (ResErrUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppResErrProcInfo, GetCurrentArchitecture())
  96. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  97.     #pragma parameter CallResErrProc(__A0, __D0)
  98.     void CallResErrProc(ResErrUPP routine, OSErr thErr) = 0x4E90;
  99. #else
  100.     #define CallResErrProc(userRoutine, thErr)                     CALL_ONE_PARAMETER_UPP((userRoutine), uppResErrProcInfo, (thErr))
  101. #endif
  102. #if !TARGET_OS_MAC
  103. /* QuickTime 3.0*/
  104. typedef CALLBACK_API( OSErr , ResourceEndianFilterPtr )(Handle theResource, Boolean currentlyNativeEndian);
  105. #endif  /* !TARGET_OS_MAC */
  106.  
  107. EXTERN_API( short )
  108. InitResources                    (void)                                                        ONEWORDINLINE(0xA995);
  109.  
  110. EXTERN_API( void )
  111. RsrcZoneInit                    (void)                                                        ONEWORDINLINE(0xA996);
  112.  
  113. EXTERN_API( void )
  114. CloseResFile                    (short                     refNum)                                ONEWORDINLINE(0xA99A);
  115.  
  116. EXTERN_API( OSErr )
  117. ResError                        (void)                                                        ONEWORDINLINE(0xA9AF);
  118.  
  119. EXTERN_API( short )
  120. CurResFile                        (void)                                                        ONEWORDINLINE(0xA994);
  121.  
  122. EXTERN_API( short )
  123. HomeResFile                        (Handle                 theResource)                        ONEWORDINLINE(0xA9A4);
  124.  
  125. EXTERN_API( void )
  126. CreateResFile                    (ConstStr255Param         fileName)                            ONEWORDINLINE(0xA9B1);
  127.  
  128. EXTERN_API( short )
  129. OpenResFile                        (ConstStr255Param         fileName)                            ONEWORDINLINE(0xA997);
  130.  
  131. EXTERN_API( void )
  132. UseResFile                        (short                     refNum)                                ONEWORDINLINE(0xA998);
  133.  
  134. EXTERN_API( short )
  135. CountTypes                        (void)                                                        ONEWORDINLINE(0xA99E);
  136.  
  137. EXTERN_API( short )
  138. Count1Types                        (void)                                                        ONEWORDINLINE(0xA81C);
  139.  
  140. EXTERN_API( void )
  141. GetIndType                        (ResType *                theType,
  142.                                  short                     index)                                ONEWORDINLINE(0xA99F);
  143.  
  144. EXTERN_API( void )
  145. Get1IndType                        (ResType *                theType,
  146.                                  short                     index)                                ONEWORDINLINE(0xA80F);
  147.  
  148. EXTERN_API( void )
  149. SetResLoad                        (Boolean                 load)                                ONEWORDINLINE(0xA99B);
  150.  
  151. EXTERN_API( short )
  152. CountResources                    (ResType                 theType)                            ONEWORDINLINE(0xA99C);
  153.  
  154. EXTERN_API( short )
  155. Count1Resources                    (ResType                 theType)                            ONEWORDINLINE(0xA80D);
  156.  
  157. EXTERN_API( Handle )
  158. GetIndResource                    (ResType                 theType,
  159.                                  short                     index)                                ONEWORDINLINE(0xA99D);
  160.  
  161. EXTERN_API( Handle )
  162. Get1IndResource                    (ResType                 theType,
  163.                                  short                     index)                                ONEWORDINLINE(0xA80E);
  164.  
  165. EXTERN_API( Handle )
  166. GetResource                        (ResType                 theType,
  167.                                  short                     theID)                                ONEWORDINLINE(0xA9A0);
  168.  
  169. EXTERN_API( Handle )
  170. Get1Resource                    (ResType                 theType,
  171.                                  short                     theID)                                ONEWORDINLINE(0xA81F);
  172.  
  173. EXTERN_API( Handle )
  174. GetNamedResource                (ResType                 theType,
  175.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9A1);
  176.  
  177. EXTERN_API( Handle )
  178. Get1NamedResource                (ResType                 theType,
  179.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA820);
  180.  
  181. #if TARGET_OS_MAC
  182.     #define MacLoadResource LoadResource
  183. #endif
  184. EXTERN_API( void )
  185. MacLoadResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9A2);
  186.  
  187. EXTERN_API( void )
  188. ReleaseResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9A3);
  189.  
  190. EXTERN_API( void )
  191. DetachResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA992);
  192.  
  193. EXTERN_API( short )
  194. UniqueID                        (ResType                 theType)                            ONEWORDINLINE(0xA9C1);
  195.  
  196. EXTERN_API( short )
  197. Unique1ID                        (ResType                 theType)                            ONEWORDINLINE(0xA810);
  198.  
  199. EXTERN_API( short )
  200. GetResAttrs                        (Handle                 theResource)                        ONEWORDINLINE(0xA9A6);
  201.  
  202. EXTERN_API( void )
  203. GetResInfo                        (Handle                 theResource,
  204.                                  short *                theID,
  205.                                  ResType *                theType,
  206.                                  Str255                 name)                                ONEWORDINLINE(0xA9A8);
  207.  
  208. EXTERN_API( void )
  209. SetResInfo                        (Handle                 theResource,
  210.                                  short                     theID,
  211.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9A9);
  212.  
  213. EXTERN_API( void )
  214. AddResource                        (Handle                 theData,
  215.                                  ResType                 theType,
  216.                                  short                     theID,
  217.                                  ConstStr255Param         name)                                ONEWORDINLINE(0xA9AB);
  218.  
  219. EXTERN_API( long )
  220. GetResourceSizeOnDisk            (Handle                 theResource)                        ONEWORDINLINE(0xA9A5);
  221.  
  222. EXTERN_API( long )
  223. GetMaxResourceSize                (Handle                 theResource)                        ONEWORDINLINE(0xA821);
  224.  
  225. EXTERN_API( long )
  226. RsrcMapEntry                    (Handle                 theResource)                        ONEWORDINLINE(0xA9C5);
  227.  
  228. EXTERN_API( void )
  229. SetResAttrs                        (Handle                 theResource,
  230.                                  short                     attrs)                                ONEWORDINLINE(0xA9A7);
  231.  
  232. EXTERN_API( void )
  233. ChangedResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9AA);
  234.  
  235. EXTERN_API( void )
  236. RemoveResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9AD);
  237.  
  238. EXTERN_API( void )
  239. UpdateResFile                    (short                     refNum)                                ONEWORDINLINE(0xA999);
  240.  
  241. EXTERN_API( void )
  242. WriteResource                    (Handle                 theResource)                        ONEWORDINLINE(0xA9B0);
  243.  
  244. EXTERN_API( void )
  245. SetResPurge                        (Boolean                 install)                            ONEWORDINLINE(0xA993);
  246.  
  247. EXTERN_API( short )
  248. GetResFileAttrs                    (short                     refNum)                                ONEWORDINLINE(0xA9F6);
  249.  
  250. EXTERN_API( void )
  251. SetResFileAttrs                    (short                     refNum,
  252.                                  short                     attrs)                                ONEWORDINLINE(0xA9F7);
  253.  
  254. EXTERN_API( short )
  255. OpenRFPerm                        (ConstStr255Param         fileName,
  256.                                  short                     vRefNum,
  257.                                  SInt8                     permission)                            ONEWORDINLINE(0xA9C4);
  258.  
  259. EXTERN_API( Handle )
  260. RGetResource                    (ResType                 theType,
  261.                                  short                     theID)                                ONEWORDINLINE(0xA80C);
  262.  
  263. /*
  264.     Note:     The HOpenResFile trap was not implemented until System 7.  If you want to call HOpenResFile
  265.             while running on System 6 machines, then define USE_HOPENRESFILE_GLUE and link with
  266.             Interface.o which contains glue to implement HOpenResFile on pre-System 7 machines.
  267. */
  268. #ifdef USE_HOPENRESFILE_GLUE
  269. EXTERN_API( short )
  270. HOpenResFile                    (short                     vRefNum,
  271.                                  long                     dirID,
  272.                                  ConstStr255Param         fileName,
  273.                                  SInt8                     permission);
  274.  
  275. #else
  276. EXTERN_API( short )
  277. HOpenResFile                    (short                     vRefNum,
  278.                                  long                     dirID,
  279.                                  ConstStr255Param         fileName,
  280.                                  SInt8                     permission)                            ONEWORDINLINE(0xA81A);
  281.  
  282. #endif  /* defined(USE_HOPENRESFILE_GLUE) */
  283.  
  284. /*
  285.     Note:     The HCreateResFile trap was not implemented until System 7.  If you want to call HCreateResFile
  286.             while running on System 6 machines, then define USE_HCREATERESFILE_GLUE and link with
  287.             Interface.o which contains glue to implement HCreateResFile on pre-System 7 machines.
  288. */
  289. #ifdef USE_HCREATERESFILE_GLUE
  290. EXTERN_API( void )
  291. HCreateResFile                    (short                     vRefNum,
  292.                                  long                     dirID,
  293.                                  ConstStr255Param         fileName);
  294.  
  295. #else
  296. EXTERN_API( void )
  297. HCreateResFile                    (short                     vRefNum,
  298.                                  long                     dirID,
  299.                                  ConstStr255Param         fileName)                            ONEWORDINLINE(0xA81B);
  300.  
  301. #endif  /* defined(USE_HCREATERESFILE_GLUE) */
  302.  
  303. EXTERN_API( short )
  304. FSpOpenResFile                    (const FSSpec *            spec,
  305.                                  SignedByte             permission)                            TWOWORDINLINE(0x700D, 0xAA52);
  306.  
  307. EXTERN_API( void )
  308. FSpCreateResFile                (const FSSpec *            spec,
  309.                                  OSType                 creator,
  310.                                  OSType                 fileType,
  311.                                  ScriptCode             scriptTag)                            TWOWORDINLINE(0x700E, 0xAA52);
  312.  
  313. EXTERN_API( void )
  314. ReadPartialResource                (Handle                 theResource,
  315.                                  long                     offset,
  316.                                  void *                    buffer,
  317.                                  long                     count)                                TWOWORDINLINE(0x7001, 0xA822);
  318.  
  319. EXTERN_API( void )
  320. WritePartialResource            (Handle                 theResource,
  321.                                  long                     offset,
  322.                                  const void *            buffer,
  323.                                  long                     count)                                TWOWORDINLINE(0x7002, 0xA822);
  324.  
  325. EXTERN_API( void )
  326. SetResourceSize                    (Handle                 theResource,
  327.                                  long                     newSize)                            TWOWORDINLINE(0x7003, 0xA822);
  328.  
  329. EXTERN_API( Handle )
  330. GetNextFOND                        (Handle                 fondHandle)                            TWOWORDINLINE(0x700A, 0xA822);
  331.  
  332.  
  333. #if !TARGET_OS_MAC
  334. /* QuickTime 3.0*/
  335. EXTERN_API_C( OSErr )
  336. RegisterResourceEndianFilter    (ResType                 theType,
  337.                                  ResourceEndianFilterPtr  theFilterProc);
  338.  
  339. #endif  /* !TARGET_OS_MAC */
  340.  
  341. /* Use TempInsertROMMap to force the ROM resource map to be
  342.    inserted into the chain in front of the system. Note that
  343.    this call is only temporary - the modified resource chain
  344.    is only used for the next call to the resource manager.
  345.    See IM IV 19 for more information. 
  346. */
  347. EXTERN_API( void )
  348. TempInsertROMMap                (Boolean                 tempResLoad)                        FIVEWORDINLINE(0x70FF, 0x4A1F, 0x56C0, 0x31C0, 0x0B9E);
  349.  
  350.  
  351. #if CGLUESUPPORTED
  352. EXTERN_API_C( Handle )
  353. getnamedresource                (ResType                 theType,
  354.                                  const char *            name);
  355.  
  356. EXTERN_API_C( Handle )
  357. get1namedresource                (ResType                 theType,
  358.                                  const char *            name);
  359.  
  360. EXTERN_API_C( short )
  361. openrfperm                        (const char *            fileName,
  362.                                  short                     vRefNum,
  363.                                  char                     permission);
  364.  
  365. EXTERN_API_C( short )
  366. openresfile                        (const char *            fileName);
  367.  
  368. EXTERN_API_C( void )
  369. createresfile                    (const char *            fileName);
  370.  
  371. EXTERN_API_C( void )
  372. getresinfo                        (Handle                 theResource,
  373.                                  short *                theID,
  374.                                  ResType *                theType,
  375.                                  char *                    name);
  376.  
  377. EXTERN_API_C( void )
  378. setresinfo                        (Handle                 theResource,
  379.                                  short                     theID,
  380.                                  const char *            name);
  381.  
  382. EXTERN_API_C( void )
  383. addresource                        (Handle                 theResource,
  384.                                  ResType                 theType,
  385.                                  short                     theID,
  386.                                  const char *            name);
  387.  
  388. #endif  /* CGLUESUPPORTED */
  389.  
  390. #if OLDROUTINENAMES
  391. #define SizeResource(theResource) GetResourceSizeOnDisk(theResource)
  392. #define MaxSizeRsrc(theResource) GetMaxResourceSize(theResource)
  393. #define RmveResource(theResource) RemoveResource(theResource)
  394.  
  395. #endif  /* OLDROUTINENAMES */
  396.  
  397. /*
  398.     These typedefs were originally created for the Copland Resource Mangager
  399. */
  400. typedef short                             ResFileRefNum;
  401. typedef short                             ResID;
  402. typedef short                             ResAttributes;
  403. typedef short                             ResFileAttributes;
  404.  
  405.  
  406.  
  407. #if PRAGMA_STRUCT_ALIGN
  408.     #pragma options align=reset
  409. #elif PRAGMA_STRUCT_PACKPUSH
  410.     #pragma pack(pop)
  411. #elif PRAGMA_STRUCT_PACK
  412.     #pragma pack()
  413. #endif
  414.  
  415. #ifdef PRAGMA_IMPORT_OFF
  416. #pragma import off
  417. #elif PRAGMA_IMPORT
  418. #pragma import reset
  419. #endif
  420.  
  421. #ifdef __cplusplus
  422. }
  423. #endif
  424.  
  425. #endif /* __RESOURCES__ */
  426.  
  427.